// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using Elastic.Transport.Extensions;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class PutTrainedModelAliasRequestParameters : RequestParameters
{
	/// <summary>
	/// <para>
	/// Specifies whether the alias gets reassigned to the specified trained
	/// model if it is already assigned to a different model. If the alias is
	/// already assigned and this parameter is false, the API returns an error.
	/// </para>
	/// </summary>
	public bool? Reassign { get => Q<bool?>("reassign"); set => Q("reassign", value); }
}

/// <summary>
/// <para>
/// Create or update a trained model alias.
/// A trained model alias is a logical name used to reference a single trained
/// model.
/// You can use aliases instead of trained model identifiers to make it easier to
/// reference your models. For example, you can use aliases in inference
/// aggregations and processors.
/// An alias must be unique and refer to only a single trained model. However,
/// you can have multiple aliases for each trained model.
/// If you use this API to update an alias such that it references a different
/// trained model ID and the model uses a different type of data frame analytics,
/// an error occurs. For example, this situation occurs if you have a trained
/// model for regression analysis and a trained model for classification
/// analysis; you cannot reassign an alias from one type of trained model to
/// another.
/// If you use this API to update an alias and there are very few input fields in
/// common between the old and new trained models for the model alias, the API
/// returns a warning.
/// </para>
/// </summary>
public sealed partial class PutTrainedModelAliasRequest : PlainRequest<PutTrainedModelAliasRequestParameters>
{
	public PutTrainedModelAliasRequest(Elastic.Clients.Elasticsearch.Serverless.Id modelId, Elastic.Clients.Elasticsearch.Serverless.Name modelAlias) : base(r => r.Required("model_id", modelId).Required("model_alias", modelAlias))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutTrainedModelAlias;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => false;

	internal override string OperationName => "ml.put_trained_model_alias";

	/// <summary>
	/// <para>
	/// Specifies whether the alias gets reassigned to the specified trained
	/// model if it is already assigned to a different model. If the alias is
	/// already assigned and this parameter is false, the API returns an error.
	/// </para>
	/// </summary>
	[JsonIgnore]
	public bool? Reassign { get => Q<bool?>("reassign"); set => Q("reassign", value); }
}

/// <summary>
/// <para>
/// Create or update a trained model alias.
/// A trained model alias is a logical name used to reference a single trained
/// model.
/// You can use aliases instead of trained model identifiers to make it easier to
/// reference your models. For example, you can use aliases in inference
/// aggregations and processors.
/// An alias must be unique and refer to only a single trained model. However,
/// you can have multiple aliases for each trained model.
/// If you use this API to update an alias such that it references a different
/// trained model ID and the model uses a different type of data frame analytics,
/// an error occurs. For example, this situation occurs if you have a trained
/// model for regression analysis and a trained model for classification
/// analysis; you cannot reassign an alias from one type of trained model to
/// another.
/// If you use this API to update an alias and there are very few input fields in
/// common between the old and new trained models for the model alias, the API
/// returns a warning.
/// </para>
/// </summary>
public sealed partial class PutTrainedModelAliasRequestDescriptor : RequestDescriptor<PutTrainedModelAliasRequestDescriptor, PutTrainedModelAliasRequestParameters>
{
	internal PutTrainedModelAliasRequestDescriptor(Action<PutTrainedModelAliasRequestDescriptor> configure) => configure.Invoke(this);

	public PutTrainedModelAliasRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Id modelId, Elastic.Clients.Elasticsearch.Serverless.Name modelAlias) : base(r => r.Required("model_id", modelId).Required("model_alias", modelAlias))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutTrainedModelAlias;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => false;

	internal override string OperationName => "ml.put_trained_model_alias";

	public PutTrainedModelAliasRequestDescriptor Reassign(bool? reassign = true) => Qs("reassign", reassign);

	public PutTrainedModelAliasRequestDescriptor ModelAlias(Elastic.Clients.Elasticsearch.Serverless.Name modelAlias)
	{
		RouteValues.Required("model_alias", modelAlias);
		return Self;
	}

	public PutTrainedModelAliasRequestDescriptor ModelId(Elastic.Clients.Elasticsearch.Serverless.Id modelId)
	{
		RouteValues.Required("model_id", modelId);
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
	}
}